package com.weetop.akly.presenter;

import android.app.Activity;

import com.weetop.akly.base.mvp.BaseModel;
import com.weetop.akly.base.mvp.BaseObserver;
import com.weetop.akly.base.mvp.BasePresenter;
import com.weetop.akly.bean.AccountInfoBean;
import com.weetop.akly.bean.RongImUserInfoBean;
import com.weetop.akly.view.AccountView;

public class AccountInfoPresent extends BasePresenter<AccountView> {
    public AccountInfoPresent(AccountView baseView, Activity activity) {
        super(baseView, activity);
    }

    /**
     * 获取个人信息接口
     */
    public void getAccountInfo(){
        addDisposable(apiServer.getAccountInfo(), new BaseObserver<BaseModel<AccountInfoBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<AccountInfoBean> o) {
                baseView.getAccountInfoSuccess(o);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
    /**
     * 获取融云用户信息接口
     */
    public void getRongIMUserInfo(String userId){
        addDisposable(apiServer.getRongImUserInfo(userId), new BaseObserver<BaseModel<RongImUserInfoBean>>(baseView) {
            @Override
            public void onSuccess(BaseModel<RongImUserInfoBean> o) {
                baseView.getRongIMUserInfoSuccess(o,userId);
            }

            @Override
            public void onError(String msg) {
                if (baseView != null) {
                    baseView.showError(msg);
                }
            }
        });
    }
}
